package com.tianqu.tms.www.car.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tianqu.tms.core.base.Logger;
import com.tianqu.tms.core.base.TmsAction;
import com.tianqu.tms.core.base.UserContext;
import com.tianqu.tms.core.util.TmsConstants;
import com.tianqu.tms.www.car.actionform.CarSearchInputActionForm;
import com.tianqu.tms.www.car.controller.CarSearchInputTopController;


public class CarSearchInputAction extends TmsAction{

	
	private Logger logger = Logger.getLogger(CarSearchInputAction.class);
	public static final String INPUT = "input";
	public static final String CARDETAIL = "carDetail";
	@Override
	protected ActionForward doAction(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response,
			UserContext uc) throws Exception {
		
		logger.debug(this.getClass().getName() + "#execute was called.");
		CarSearchInputActionForm carSearchInputActionForm = (CarSearchInputActionForm)form;
		
		CarSearchInputTopController carSearchInputController = new CarSearchInputTopController();
		carSearchInputController.execute(uc);

		logger.debug(this.getClass().getName() + "#doAction was completed.");
		if(uc.getAttribute("licensePlate") != null && ""!=uc.getAttribute("licensePlate")){
			//详细页
			request.setAttribute(TmsConstants.VIEWHELP, uc.getAttribute(TmsConstants.VIEWHELP));
			return mapping.findForward(CARDETAIL);
		}else{
			//添加页  将vin放到viewhelp中
			request.setAttribute(TmsConstants.VIEWHELP, uc.getAttribute(TmsConstants.VIEWHELP));
			return mapping.findForward(INPUT);
		}
		
		
		
	}

}
